import publicForm from "@/components/public/el-form.vue"; //弹框form

import {
  addProtectioncourse,
  getProtectioncourseByFid, //详情
  htgetStationWarnByCompanyId, //获取审核流程
  rebarAddClosedForm
} from "@/api/request.js";
export default {
  props: [
    "dialogVisible",
    "dialogTitle",
    "statusNum",
    "currentRow",
  ],
  data() {
    return {
      visible: "",
      loading: false,
      title: "闭合处理",
      isLock: false,
      dialogHeight: null,

      // 基本信息
      // basicFormObj: formJs.basicFormObj,
      // basicFormData: {},
      // 基本信息

      // 闭合
      activeIndex: "1",
      activeNames: ["0"],
      addData: null, //反调新增接口
      recordData: [{
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
      ], //记录表1-20数据
      recordData1: [{
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
        {
          fId: "", //测点fid
          fParentid: "", //测点对应信息表fid
          fCheckpointnumber: null, //测点编号
          fFirstcheckvalue: "", //第一次检测值
          fSecondcheckvalue: "", //第二次检测值
          fAvgvalue: "", //平均值
          fSdvalue: "", //偏差值
          fResultdecide: "", //结果判定
          fIsdeleted: null,
        },
      ], //记录表21-40数据

      formData: {
        fId: null, //信息表fid
        fCompanyid: null, //对应机构id
        fCompanyname: null, //对应机构名称
        fProjectid: null, //工程id
        fProjectname: null, //工程名称简称
        fProjectfullname: null, //工程名称全称
        fChecktype: null, //检测类型
        fCheckcompanyid: null, //检测单位id
        fCheckcompanyname: null, //检测单位简称
        fCheckcompanyfullname: null, //检测单位全称
        fClientid: null, //施工委托单位id
        fClientname: null, //施工委托单位简称
        fClientfullname: null, //施工委托单位全称
        fProjectpart: null, //工程部位
        fProjectapplication: null, //工程用途
        fSamplenumber: null, //样品编号
        fSamplename: null, //样品名称
        fSampledescription: null, //样品描述
        fMajorequipnameandnumber: null, //主要仪器设备名称及编号
        fMajorequipname: null,
        fMajorequipnumber: null,
        fCheckenvironment: null, //试验条件
        fRecordnumber: null, //记录编号
        fCheckdate: null,
        fCheckdates: null, //试验检测日期
        fCheckreference: null, //检测依据
        fDecidereference: null, //判定依据
        fComponentname: null, //构件名称
        fDnd: null, //保护层厚度设计值
        fCo: null, //垫块厚度Co
        fStandardvalue: null, //规定值或允许偏差
        fDiameter: null, //钢筋公称直径
        fCc: null, //修正值
        fReportnumber: null, //报告编号
        fAddcomments: null, //附加说明
        fCheckresult: null, //检测结论
        fCheckpointcount: null, //保护层厚度检测点数
        fCheckpointqualifiedcount: null, //合格点数
        fCheckpointqualifiedrate: null, //合格率
        fCheckpointavgthickness: null, //保护层厚度平均值
        fSd: null, //标准偏差
        fDne: null, //保护层厚度特征值
        fRatioofdneanddnd: null, //保护层厚度特征值与设计值的比值   DNE/DND
      },
      sample: null, //样品信息

      newRow: null,
      Thickness_FormData_right: [],
      Thickness_FormData_left: [],
      chartsLoading: false,
      tensioningData: [], //张拉力--图表数据


    };
  },
  components: {
    publicForm,
  },
  watch: {
    dialogVisible: {
      handler(newVal) {
        if (newVal) {
          this.visible = newVal;
        }
      },
      immediate: true,
    },

    dialogTitle: {
      handler(newVal) {
        if (newVal) {
          this.title = newVal;
        }
      },
      immediate: true,
    },

    statusNum: {
      handler(newVal) {
        if (newVal) {
          this.edit(newVal);
        }
      },
      immediate: true,
    },

    currentRow: {
      handler(newVal) {
        this.newRow = newVal;
      },
      deep: true,
      immediate: true,
    },
  },
  created() {
    window.addEventListener("resize", this.getHeight);
    this.getHeight();
  }, //获取页面高度自适应：

  destroyed() {
    window.removeEventListener("resize", this.getHeight);
    this.getHeight();
  },
  mounted() {
    this.userInfo = JSON.parse(sessionStorage.getItem("GxBack-userInfo"));
    this.btnShow = true;
    this.getDetail(this.newRow);

    this.getHeight();
  },
  methods: {
    // 折叠面板
    changeCollapse(e) {
      // console.log(this.activeNames, e);
      return e;
    },
    getHeight() {
      var h = document.documentElement.clientHeight; //获取页面可见高度
      this.dialogHeight = h * 0.93 + "px";
    },
    closeDialog() {
      this.$emit("close");
    },
    selectChange(data, a, b) {
      // console.log("selectChange", data, a, b);
      return data, a, b;
    },
    edit() {
      this.closeFormData = this.$options.data.call(this).closeFormData;
    },

    // 详情
    getDetail(row, num) {
      this.fPhotofilelist = [];
      this.fId = row.fId;
      if (this.fId != null && this.fId != "") {
        this.recordData = [];
        this.recordData1 = [];
        this.dialogTableVisible = true;
        this.loadingDialog = true;
        if (num == 1) {
          this.activeIndex = "1";
        } else if (num == 2) {
          this.activeIndex = "1";
        } else if (num == 3) {
          this.activeIndex = "1";
        } else if (num == 4) {
          this.activeIndex = "2";
        }
        getProtectioncourseByFid({
            fId: this.fId
          })
          .then((res) => {
            if (res.errcode == 0) {
              var that = this;
              that.loadingDialog = false;
              that.formData = res.data.checkProtectioncourse;
              // 钢筋保护层厚度检测示意图
              var Thickness_FormData = [];
              this.Thickness_FormData_right = [];
              this.Thickness_FormData_left = [];
              this.tensioningData = [
                [],
                [], "", []
              ];
              // this.tensioningData = [[X轴数据], [Y轴数据], "标准线"];
              var dataFrom = {
                Number: null, //序号
                fAddress: "", //位置
                fFirstcheckvalue: "", //厚度
                fCheckpointnumber: "", //间距
                fXy: "", //是否合格
              };

              that.formData.checkPointList.map((item, index) => {
                if (item.fXy == "-1") {
                  item.fXy = "不合格";
                } else if (item.fXy == "1") {
                  item.fXy = "合格";
                }
                if (index == 0) {
                  dataFrom = {
                    Number: index + 1,
                    fAddress: item.fAddress,
                    fFirstcheckvalue: item.fFirstcheckvalue,
                    fCheckpointnumber: item.fAddress,
                    fXy: item.fXy,
                  };
                } else {
                  if (
                    item.fFirstcheckvalue == "" ||
                    item.fFirstcheckvalue == null
                  ) {
                    dataFrom = {
                      Number: index + 1,
                      fAddress: "/",
                      fFirstcheckvalue: "/",
                      fCheckpointnumber: "/",
                      fXy: "/",
                    };
                  } else {
                    dataFrom = {
                      Number: index + 1,
                      fAddress: item.fAddress,
                      fFirstcheckvalue: item.fFirstcheckvalue,
                      fCheckpointnumber: (
                        item.fAddress -
                        that.formData.checkPointList[index - 1].fAddress
                      ).toString(),
                      fXy: item.fXy,
                    };
                  }
                }

                if (dataFrom.fFirstcheckvalue != "/") {
                  this.tensioningData[0].push(dataFrom.fAddress);
                }
                if (dataFrom.fCheckpointnumber != "/") {
                  this.tensioningData[1].push(dataFrom.fFirstcheckvalue);
                  this.tensioningData[3].push(dataFrom.fCheckpointnumber);
                }

                // fCheckpointnumber
                this.tensioningData[2] = this.formData.fDnd;
                Thickness_FormData.push(dataFrom);
              });

              Thickness_FormData.map((item, index) => {
                if (index < 20) {
                  this.Thickness_FormData_right.push(item);
                } else {
                  this.Thickness_FormData_left.push(item);
                }
              });
              // 钢筋保护层厚度检测示意图

              that.addData = res.data;
              for (
                let index = 0; index < that.formData.checkPointList.length; index++
              ) {
                const element = that.formData.checkPointList[index];
                if (index < 20) {
                  that.recordData.push(element);
                } else {
                  that.recordData1.push(element);
                }
              }
              that.sample =
                "样品名称:" +
                that.formData.fSamplename +
                "; " +
                "样品编号:" +
                that.formData.fSamplenumber +
                "; " +
                "样品状态:" +
                that.formData.fSampledescription +
                "; ";
              that.fPhotofilelist = res.data.checkpartimage;
              // 计算
              if (
                this.formData.fDiameter != "" &&
                this.formData.fCc != "" &&
                this.formData.fDnd != "" &&
                this.formData.fCo != "" &&
                this.formData.fStandardvalue != "" &&
                this.formData.fDiameter != null &&
                this.formData.fCc != null &&
                this.formData.fDnd != null &&
                this.formData.fCo != null &&
                this.formData.fStandardvalue != null
              ) {
                this.inputCheckpointnumber();
              } else {
                console.log("值不全，无法自动计算");
              }
              // 计算
            } else {
              this.$message.error("记录表/报告表", res.msg);
              this.loadingDialog = false;
            }
          })
          .catch(() => {
            console.log("记录表/报告表");
            this.loadingDialog = false;
          });
      } else {
        return this.$message.error("请先选择需查看的数据");
      }
    },
    // 计算
    inputCheckpointnumber() {
      // this.formData.checkPointList = this.recordData.concat(this.recordData1);
      // 钢筋工称直径和修正值带入
      for (
        let index = 0; index < this.formData.checkPointList.length; index++
      ) {
        const element = this.formData.checkPointList[index];
        if (
          element.fSecondcheckvalue != "" &&
          element.fSecondcheckvalue != null &&
          element.fFirstcheckvalue != null &&
          element.fFirstcheckvalue != ""
        ) {
          element.fDiameter = this.formData.fDiameter;
          element.fCc = this.formData.fCc;
          //  平均检测值
          if (
            Number(element.fFirstcheckvalue - element.fSecondcheckvalue) > 1 ||
            Number(element.fSecondcheckvalue - element.fFirstcheckvalue) > 1
          ) {
            element.fAvgvalue = "无效";
            element.fSdvalue = "无效";
          } else {
            var Avgvalue;
            Avgvalue =
              (Number(element.fSecondcheckvalue) +
                Number(element.fFirstcheckvalue) +
                2 * Number(element.fCc) -
                2 * Number(this.formData.fCo)) /
              2;

            if (parseInt(Avgvalue) === parseFloat(Avgvalue)) {
              element.fAvgvalue = Avgvalue.toFixed(0);
            } else {
              var arr = Avgvalue.toString().split(".");
              if (arr[1].length > 1) {
                element.fAvgvalue = arr[0] - 0 + 1;
              } else {
                if ((arr[0] - 0) % 2 == 0) {
                  element.fAvgvalue = arr[0] - 0;
                } else {
                  element.fAvgvalue = arr[0] - 0 + 1;
                }
              }
            }

            element.fAvgvalue = element.fAvgvalue + "";

            //偏差值
            element.fSdvalue = Number(element.fAvgvalue - this.formData.fDnd)
              .toFixed(0)
              .toString();
          }
        } else {
          element.fDiameter = "";
          element.fAvgvalue = "";
          element.fSdvalue = "";
          element.fResultdecide = "";
          element.fCc = "";
        }
      }

      this.calculation();
    },

    calculation() {
      let CheckpointcountNum = 0; //  检测点数
      let StandardvaluNum = 0; //合格点数
      let StandardvaluNums = 0; //有效点数
      let StandardvaluNumAllin = 0; //所有合格点数平均值总和
      let fSdvaluNum = 0; //偏差平方总和
      let standard = 0; //标准差
      let Checkpointavgthickness = 0; //保护层厚度平均值
      let features = 0; //保护层厚度特征值

      for (
        let index = 0; index < this.formData.checkPointList.length; index++
      ) {
        const element = this.formData.checkPointList[index];
        // 检测点数
        if (element.fFirstcheckvalue != "" || element.fSecondcheckvalue != "") {
          CheckpointcountNum++;
          // 判定系数
          if (CheckpointcountNum >= 25) {
            this.formData.fThicknessdecidecoefficient = "1.595";
          } else if (24 >= CheckpointcountNum && CheckpointcountNum >= 16) {
            this.formData.fThicknessdecidecoefficient = "1.645";
          } else if (15 >= CheckpointcountNum && CheckpointcountNum >= 10) {
            this.formData.fThicknessdecidecoefficient = "1.695";
          }
        }

        // 合格点数
        if (element.fSdvalue != "无效" && element.fSdvalue != "") {
          var StandardvaluArr = this.formData.fStandardvalue.split(",");
          if (
            Number(StandardvaluArr[0]) <= Number(element.fSdvalue) &&
            Number(element.fSdvalue) <= Number(StandardvaluArr[1])
          ) {
            element.fResultdecide = "合格";
            StandardvaluNum++; //合格点数
          }
        } else {
          if (
            element.fFirstcheckvalue != "" ||
            element.fSecondcheckvalue != ""
          ) {
            element.fResultdecide = "不合格";
          }
        }

        this.formData.fCheckpointcount = CheckpointcountNum.toString(); //检测点数
        this.formData.fCheckpointqualifiedcount = StandardvaluNum.toString(); //合格点数
        //有效点数
        if (element.fAvgvalue != "无效" && element.fAvgvalue != "") {
          StandardvaluNums++; //有效点数
          StandardvaluNumAllin += Number(element.fAvgvalue); //所有有效点数平均值总和
        }
      }

      //保护层厚度平均值
      if (StandardvaluNums == 0) {
        this.formData.fCheckpointavgthickness = "0";
      } else {
        Checkpointavgthickness = (
          StandardvaluNumAllin / StandardvaluNums
        ).toFixed(1);
        this.formData.fCheckpointavgthickness =
          Checkpointavgthickness.toString();
      }
      //  标准差
      if (StandardvaluNums > 1) {
        for (
          let index = 0; index < this.formData.checkPointList.length; index++
        ) {
          const element = this.formData.checkPointList[index];
          // 标准差分子平方和
          if (element.fAvgvalue != "无效" && element.fAvgvalue != "") {
            fSdvaluNum += Math.pow(
              Number(element.fAvgvalue - Checkpointavgthickness),
              2
            ); //偏差平方总和
          }
        }
        standard = Math.sqrt(fSdvaluNum / (StandardvaluNums - 1)).toFixed(1);
        this.formData.fSd = standard.toString();
      } else {
        this.formData.fSd = "0";
      }
      // 保护层厚度特征值
      if (CheckpointcountNum >= 10) {
        features = (
          Checkpointavgthickness -
          standard * Number(this.formData.fThicknessdecidecoefficient)
        ).toFixed(1);
        this.formData.fDne = features.toString();
      } else {
        this.formData.fDne = "0";
      }

      //保护层厚度特征值与设计值的比值Dne/Dnd
      this.formData.fRatioofdneanddnd = (features / Number(this.formData.fDnd))
        .toFixed(1)
        .toString();

      // 合格率
      if (StandardvaluNum != 0) {
        this.formData.fCheckpointqualifiedrate = (
          (Number(this.formData.fCheckpointqualifiedcount) /
            Number(this.formData.fCheckpointcount)) *
          100
        ).toFixed(1);
      } else {
        this.formData.fCheckpointqualifiedrate = "0";
      }

      if (
        this.formData.fModifydate == "" ||
        this.formData.fModifydate == null
      ) {
        this.addProtectioncourseFun();
      }
    },
    addProtectioncourseFun() {
      this.addData.checkProtectioncourse.checkPointList =
        this.formData.checkPointList; //表格

      this.addData.checkProtectioncourse.fThicknessdecidecoefficient =
        this.formData.fThicknessdecidecoefficient; //判定系数

      this.addData.checkProtectioncourse.fCheckpointcount =
        this.formData.fCheckpointcount; //检测点数

      this.addData.checkProtectioncourse.fCheckpointqualifiedcount =
        this.formData.fCheckpointqualifiedcount; //合格点数

      this.addData.checkProtectioncourse.fCheckpointqualifiedrate =
        this.formData.fCheckpointqualifiedrate; //合格率

      this.addData.checkProtectioncourse.fCheckpointavgthickness =
        this.formData.fCheckpointavgthickness; //保护层厚度平均值

      this.addData.checkProtectioncourse.fSd = this.formData.fSd; //标准差

      this.addData.checkProtectioncourse.fDne = this.formData.fDne; // 保护层厚度特征值

      this.addData.checkProtectioncourse.fRatioofdneanddnd =
        this.formData.fRatioofdneanddnd; //保护层厚度特征值与设计值的比值Dne/Dnd
      this.addData.checkProtectioncourse.isSubmit = "1";
      addProtectioncourse(this.addData.checkProtectioncourse)
        .then((res) => {
          if (res.errcode == 0) {
            console.log("页面重新计算---保存成功");
          } else {
            console.log("页面重新计算---保存失败");
            this.loading = false;
          }
        })
        .catch(() => {
          console.log("页面重新计算---保存接口失败");
          this.loading = false;
        });
    },
    getExamine(data) {

      var status = data.fCheckstatus;
      htgetStationWarnByCompanyId({
          fCompanyid: data.fCompanyid
        })
        .then((res) => {
          if (res.errcode == 0) {
            var arr = res.data.yjQmpMsCheckEntitywarn.fAduitUser2.split("-");
            this.userInfo = JSON.parse(sessionStorage.getItem("GxBack-userInfo"));
            this.btnShow = true;
            console.log(this.userInfo.companyNature, arr[status], arr, status);
            if ((this.userInfo.companyNature == arr[status])) {
              if (status == 0) {
                // 闭合申请单 可编辑
                this.handNum = true; //闭合申请单
                this.firstNum = false; //一级审核
                this.secondNum = false; //二级审核
                this.activeNames = ["0"];
                if (this.closeFormData.fHandledates == null || this.closeFormData.fHandledates == "") {
                  this.closeFormData.fHandledates = this.common.day(0);
                  this.closeFormData.fHandleusername = this.userInfo.realName; //处理人
                }
                // 闭合申请单
                this.closeFormObj.map((item) => {
                  item.disabled = false;
                });
                this.closeFormObj[3].disabled = true;
                this.closeFormObj[4].disabled = true;
                // 闭合申请单
                // 一级审核
                this.FauditFormObj.map((item) => {
                  item.disabled = true;
                });
                // 一级审核
                //  二级闭合
                this.SauditFormObj.map((item) => {
                  item.disabled = true;
                });
                //  二级闭合
                this.closeFormObj[5].uploadSelect = true
                this.FauditFormObj[4].uploadSelect = false
                this.SauditFormObj[4].uploadSelect = false
              } else if (status == 1) {
                // 一级审核
                this.handNum = true; //闭合申请单
                this.firstNum = true; //一级审核
                this.secondNum = false; //二级审核
                this.activeNames = ["0", "1"];

                // 闭合申请单
                this.closeFormObj.map((item) => {
                  item.disabled = true;
                });
                // 闭合申请单

                // 一级审核
                this.FauditFormObj.map((item) => {
                  item.disabled = false;
                });
                this.FauditFormObj[2].disabled = true;
                this.FauditFormObj[3].disabled = true;
                if (this.closeFormData.fFirstcheckdates == null || this.closeFormData.fFirstcheckdates == "") {
                  this.closeFormData.fFirstcheckdates = this.common.day(0)
                  this.closeFormData.fFirstcheckusername = this.userInfo.realName; //一级审核人姓名
                }
                // 一级审核


                //  二级闭合
                this.SauditFormObj.map((item) => {
                  item.disabled = true;
                });
                //  二级闭合
                this.closeFormObj[5].uploadSelect = false
                this.FauditFormObj[4].uploadSelect = true
                this.SauditFormObj[4].uploadSelect = false

              } else if (status == 2) {
                //    二级审核
                this.handNum = true; //闭合申请单
                this.firstNum = true; //一级审核
                this.secondNum = true; //二级审核
                this.activeNames = ["0", "1", "2"];

                // 闭合
                this.closeFormObj.map((item) => {
                  item.disabled = true;
                });
                // 闭合
                // 一级审核
                this.FauditFormObj.map((item) => {
                  item.disabled = true;
                });

                // 一级审核
                //  二级闭合
                this.SauditFormObj.map((item) => {
                  item.disabled = false;
                });
                this.SauditFormObj[2].disabled = true;
                this.SauditFormObj[3].disabled = true;
                if (this.closeFormData.fSecondcheckdates == null || this.closeFormData.fSecondcheckdates == "") {
                  this.closeFormData.fSecondcheckdates = this.common.day(0)
                  this.closeFormData.fSecondcheckusername = this.userInfo.realName; //一级审核人姓名
                }
                //  二级闭合
                this.closeFormObj[5].uploadSelect = false
                this.FauditFormObj[4].uploadSelect = false
                this.SauditFormObj[4].uploadSelect = true
              } else if (status == 3) {
                this.btnShow = false

                this.handNum = true; //闭合申请单
                this.firstNum = true; //一级审核
                this.secondNum = true; //二级审核
                // 闭合
                this.closeFormObj.map((item) => {
                  item.disabled = true;
                });
                // 闭合
                // 一级审核
                this.FauditFormObj.map((item) => {
                  item.disabled = true;
                });
                // 一级审核
                //  二级闭合
                this.SauditFormObj.map((item) => {
                  item.disabled = true;
                });
                this.closeFormObj[5].uploadSelect = false
                this.FauditFormObj[4].uploadSelect = false
                this.SauditFormObj[4].uploadSelect = false
                //  二级闭合
              }
            } else {
              this.btnShow = false
              // 闭合
              this.closeFormObj.map((item) => {
                item.disabled = true;
              });
              // 闭合
              // 一级审核
              this.FauditFormObj.map((item) => {
                item.disabled = true;
              });
              // 一级审核
              //  二级闭合
              this.SauditFormObj.map((item) => {
                item.disabled = true;
              });
              //  二级闭合
              this.closeFormObj[5].uploadSelect = false
              this.FauditFormObj[4].uploadSelect = false
              this.SauditFormObj[4].uploadSelect = false

              if (status == 0) {
                this.handNum = true; //闭合申请单
                this.firstNum = false; //一级审核
                this.secondNum = false; //二级审核
              } else if (status == 1) {
                this.activeNames = ["0"];
                this.handNum = true; //闭合申请单
                this.firstNum = false; //一级审核
                this.secondNum = false; //二级审核

              } else if (status == 2) {
                this.activeNames = ["0", "1"]
                this.handNum = true; //闭合申请单
                this.firstNum = true; //一级审核
                this.secondNum = false; //二级审核

              } else if (status == 3) {
                this.activeNames = ["0", "1", "2"]
                this.handNum = true; //闭合申请单
                this.firstNum = true; //一级审核
                this.secondNum = true; //二级审核

              }
            }
          }
        })
        .catch((error) => {
          console.log(error);
        });
    },
    // 刪除文件
    delteFile(file, status) {
      // var obj;
      var arr;
      if (status == 0) {
        // obj = this.closeFormData;
        arr = this.closeFileurllist;
      } else if (status == 1) {
        // obj = this.FauditFormData;
        arr = this.FauditFileurllist;
      } else if (status == 2) {
        // obj = this.SauditFormData;
        arr = this.SauditFileurllist;
      }
      for (let index = 0; index < arr.length; index++) {
        if (file.uid == arr[index].uid) {
          if (arr[index].atta == undefined) {
            // obj.recordfiles.push({
            this.recordfiles.push({
              fId: arr[index].fId,
            });
          } else {
            this.recordfiles.push({
              // obj.recordfiles.push({
              fId: arr[index].atta.fId,
            });
          }
          arr.splice(index, 1);
        }
      }
    },

    yj_saveForm(data) {
      // console.log("this.newRow", this.newRow);
      var save = {
        fId: data.fId, // 申请单fid //为空判断为新增
        fCompanyid: this.newRow.fCompanyid, // 施工标段id
        fParentid: this.newRow.fId, // 对应的超标记录fid
        fReason: data.fReason, // 问题原因
        fHandleway: data.fHandleway, // 处理方式
        fHandleresult: data.fHandleresult, // 处理结果
        fHandledate: data.fHandledate,
        fHandledates: data.fHandledates, // 处理日期
        fHandleusername: data.fHandleusername, // 处理人名称
        fHandlefile: data.fHandlefile, // 附件

        fFirstcheckresult: data.fFirstcheckresult, // 一级审核处理结果
        fFirstcheckopinion: data.fFirstcheckopinion, // 一级审核处理意见
        fFirstcheckusername: data.fFirstcheckusername, // 一级审核处理人name
        fFirstcheckdates: data.fFirstcheckdates, // 一级审核处理日期
        fFirstcheckfile: data.fFirstcheckfile, // 一级审核附件

        fSecondcheckresult: data.fSecondcheckresult, // 二级审核处理结果
        fSecondcheckopinion: data.fSecondcheckopinion, // 二级审核处理意见
        fSecondcheckusername: data.fSecondcheckusername, // 二级审核处理人name
        fSecondcheckdates: data.fSecondcheckdates, // 二级审核处理日期
        fSecondcheckfile: data.fSecondcheckfile, // 二级审核附件

        aduitStatus: this.newRow.fCheckstatus, // 保存状态
        userId: this.userInfo.userId, // 当前登录人id
        userName: this.userInfo.realName, // 当前登录人姓名
        recordfiles: this.recordfiles, // 删除文件id集合
      }
      console.log("fCheckstatus", this.newRow.fCheckstatus, "保存", data);

      if (this.newRow.fCheckstatus == "0") {
        if (this.$refs.publicForm0.submitForm()) {
          this.saveForm(save);
        } else {
          console.log("error");
        }
      } else if (this.newRow.fCheckstatus == "1") {
        if (this.$refs.publicForm1.submitForm()) {
          this.saveForm(save);
        } else {
          console.log("error");
        }
      } else if (this.newRow.fCheckstatus == "2") {
        if (this.$refs.publicForm2.submitForm()) {
          this.saveForm(save);
        } else {
          console.log("error");
        }
      } else {
        console.log("error");
      }

    },
    // 保存
    saveForm(obj) {
      this.loading = true;
      this.isLock = true
      rebarAddClosedForm(obj)
        .then((res) => {
          if (res.errcode == 0) {
            this.loading = false;
            this.visible = false;
            this.$emit("refreshList");
            this.$message.success("新增成功");
            this.isLock = false
          } else {
            this.loading = false;
            this.isLock = false
            this.$message.error(res.msg);
            console.log("接口报错");
          }
        })
        .catch((error) => {
          console.log("拌合站设置-新增）", error);
        });
    },
  },
};